<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script type="text/javascript" src="../js/vue.js"></script>
    <title>组件的嵌套</title>
</head>
<body>
    <div id="root">
        <app></app>
    </div>
    <script type="text/javascript">

        //student组件
        const student = Vue.extend({
            template:`
                <div>
                    <h2>学生名称：{{name}}</h2>
                    <h2>学生年龄：{{age}}</h2>
                </div>
            `,
            data(){
                return {
                    name: 'Aurora',
                    age: 25
                }
            }
        })
        //school组件
        const school = Vue.extend({
            template:`
                <div>
                    <h2>学校名称：{{name}}</h2>
                    <h2>学校地址：{{address}}</h2>
                    <student></student>
                </div>
            `,
            data(){
                return {
                    name: '北极星',
                    address: '青岛'
                }
            },
            components:{
                student
            }
        })
        //hello组件
        const hello = Vue.extend({
            template:`
                <h1>Hello,{{who}}</h1>
            `,
            data(){
                return {
                    who: 'everyone'
                }
            }
        })
        //app组件
        const app = Vue.extend({
            template:`
                <div>
                    <hello></hello>
                    <school></school>
                </div>
                
            `,
            components:{
                hello,
                school
            }
        })


        const vm = new Vue({
            el:"#root",
            components:{
               app
            }
        })

    </script>
</body>
</html>